package offer;

public class offer_0053_2 {
    public int missingNumber(int[] nums) {
        int len=nums.length;
        if(len==1) {
            if(nums[0]==0) return 1;
            return 0;
        }
        return search(0,len-1,nums);

    }
    public int search(int left,int right,int[] nums){
        if(left==right&&right==nums.length-1&&nums[nums.length-1]<nums.length) return nums.length;
        if(left==right) return left;
        int mid=(right-left)/2+left;
        if(nums[mid]==mid) return search(mid+1,right,nums);
        return search(left,mid,nums);
    }
}
